import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CustomButton extends StatelessWidget {
  final String text; // 按钮文字
  final GestureTapCallback onTap; // 按钮事件
  final Color backgroundColor; // 按钮背景色
  final double? width; // 按钮宽带
  final double? height; // 按钮高度
  final double? radius; // 按钮圆角
  final TextStyle? textStyle; // 按钮文字样式
  final EdgeInsets? padding;
  final bool disable;

  const CustomButton({
    super.key,
    required this.text,
    required this.onTap,
    this.backgroundColor = Colors.lightBlue,
    this.width,
    this.height,
    this.radius,
    this.textStyle,
    this.padding,
    this.disable = false,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => disable ? null : onTap.call(),
      child: Container(
        padding:
            padding ?? EdgeInsets.symmetric(horizontal: 20.w, vertical: 5.h),
        width: width,
        height: height,
        decoration: BoxDecoration(
          color: backgroundColor.withAlpha(disable ? 130 : 255),
          borderRadius: BorderRadius.circular(radius ?? 10.r),
        ),
        child: Center(
          child: Text(
            text,
            style: textStyle ?? TextStyle(fontSize: 28.sp, color: Colors.white),
          ),
        ),
      ),
    );
  }
}
